const mongoose = require("mongoose");//建模前先进行数据库导入

const AdminSchema = new mongoose.Schema({
    //管理员登录类
    account: {
        type: String,
        required: true,//为空验证
        unique: true
    },
    password: {
        type: String,
        required: true,
        validate: {
            validator: function (v) {
                return /^(?=.*[a-zA-Z])(?=.*\d).{8,}$/.test(v);
            },
            message: '密码需至少8位且包含字母和数字'
        }
    },
});

//客服模型
const serVerSchema = new mongoose.Schema({
    partnerServer: {
        qrcode1: {
            type: String,
        },
        qrcode2: {
            type: String,
        },
        phone1: {
            type: String,
        },
        phone2: {
            type: String,
        },
    },
});

//创建模型
const admin = mongoose.model('admin', AdminSchema);
const server = mongoose.model('server', serVerSchema);

module.exports = { admin, server };